<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>mianshi</title>
</head>
<body>
<script>
    //1 构造函数，getName是全局变量，闭包指向一个匿名函数
    function Foo() {
        getName = function () {
            console.log(5);
        };
        return this;
    }
    //2
    Foo.getName = function () {
        console.log(4);
    };

    //3 新Foo对象上增加有个getName
    Foo.prototype.getName = function () {
        console.log(3);
    };
    //4
    //1执行后就会被覆盖，1不执行也会被5覆盖
    var getName = function () {
        console.log(2);
    };
    //5 会覆盖4，1执行后被1覆盖
    function getName() {
        console.log(1);
    }

    console.log("new Foo.getName(): "+ new Foo.getName()); //4
    console.log("new Foo().getName(): "+ new Foo().getName());//3
    console.log("new new Foo().getName(): "+ new new Foo().getName());//3
    console.log("Foo.getName(): "+ Foo.getName());//4
    console.log("getName(): "+ getName()); //5
    console.log("Foo().getName(): "+ Foo().getName());//5
    console.log("getName(): "+ getName());//5


</script>
</body>
</html>